<template >
    <el-container class="layout-container-demo" style="height: 100vh">
      <el-aside width="200px">
        <el-scrollbar>
          <h3 class="menu-title">厚溥云课堂管理系统</h3>
          <el-menu
          router
          active-text-color="#ffd04b"
          background-color="#545c64"
          class="el-menu-vertical-demo"
          default-active="2"
          text-color="#fff"
        >
        <template v-for="(item,) in menus" :key="item.path" >

           <el-sub-menu v-if="!item.hidden" :index="item.path">
            <template #title>
              <el-icon>
                <component :is="item.meta.icon"></component>
              </el-icon>
              <!-- <el-icon><Avatar /></el-icon> -->
              <span>{{item.meta.title}}</span>
            </template>
              <el-menu-item v-for="(subitem,) in item.children" :index="`${item.path}/${subitem.path}`" :key="item.path+subitem.path">{{subitem.meta.title}}</el-menu-item>
              
          </el-sub-menu>
        </template>
         
          
        </el-menu>
        </el-scrollbar>
      </el-aside>
  
      <el-container>
        <el-header style="text-align: right; font-size: 20px">
          <div class="toolbar">
            <el-dropdown>
              <el-icon style="margin-right: 8px; margin-top: 1px ;font-size: 18px; color: white;"
                ><setting
              /></el-icon>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item @click="logout">退出</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
            <span style="font-size:18px;">{{userStore.userInfo.userName}}</span>
          </div>
        </el-header>
  
        <el-main>
          <!-- 主内容区域 -->
          <el-card>
              <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <template v-for="(item,index) in route.matched" :key="index">
                  <el-breadcrumb-item v-if="item.path!=='/'&&item.path!=='/home'">
                  <router-link :to="item.path">{{item.meta.title}}</router-link>
                  </el-breadcrumb-item>
                </template>
              </el-breadcrumb>
            </el-card>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </template>
  
  <script setup>
  import Menus from '../components/Menus.vue'
  import {useUserInfo} from '../store'
  import {useRoute,useRouter} from 'vue-router'
  import { ElMessage, ElMessageBox } from 'element-plus'
  const userStore = useUserInfo()
  const route = useRoute()
  const router = useRouter()
  //点击退出
  const logout=()=>{
    ElMessageBox.confirm(
    '您确定要退出吗?',
    '系统提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      // ElMessage({
      //   type: 'success',
      //   message: 'Delete completed',
      // })

      //清除用户token信息
      localStorage.removeItem('member_token')
      //跳转至登录页面
        router.push('/login')
    })
    .catch(() => {
     
    })
  }
 
  </script>
  
  <style>
  body{
    margin: 0;
  }
  .layout-container-demo .el-header {
    position: relative;
    background-color: #545c64;
    color:#fff;
  }
  .layout-container-demo .el-aside {
    color: var(--el-text-color-primary);
    background: #545c64;
  }
  .layout-container-demo .el-menu {
    border-right: none;
  }
  .layout-container-demo .el-main {
    padding: 0;
  }
  .layout-container-demo .toolbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    right: 20px;
  }
  .menu-title{
    text-align: center;
    color: white;
  }
  </style>
  
   
  